package com.mk.admin.controller;

import com.mk.admin.log.WriteLog;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.vo.MenuVo;
import com.mk.admin.service.MenuService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/a/adm/menu")
@Api(tags = "功能菜单")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @WriteLog("菜单查询")
    @PostMapping("/select")
    public ResultDto select(@RequestBody MenuVo vo) {
        return menuService.select(vo);
    }

    @WriteLog("菜单增加")
    @PostMapping("/add")
    public ResultDto add(@RequestBody MenuVo vo) {
        return menuService.add(vo);
    }

    @WriteLog("菜单修改")
    @PostMapping("/update")
    public ResultDto update(@RequestBody MenuVo vo) {
        return menuService.update(vo);
    }

    @WriteLog("菜单删除")
    @PostMapping("/delete")
    public ResultDto delete(@RequestBody MenuVo vo) {
        return menuService.delete(vo.getId());
    }

    @WriteLog("批量菜单删除")
    @PostMapping("/deleteBatchIds")
    public ResultDto deleteBatchIds(@RequestBody List<MenuVo> list) {
        return menuService.deleteBatchIds(list);
    }

    @WriteLog("菜单修改状态")
    @PostMapping("/status")
    public ResultDto status(@RequestBody MenuVo vo) {
        return menuService.status(vo.getId());
    }
}
